feat: added support for --output json and --output yaml for cancel command for pipelinerun and taskrun - #3241
anwesha-palit-redhat wants to merge 1 commit into
Conversation
|
/hold Note: This PR depends on |
| @@ -0,0 +1,112 @@ | |||
| // Copyright © 2026 The Tekton Authors. | |||
There was a problem hiding this comment.
all of these tests can probably use table test instead (lke we do generally in other tekton code)
There was a problem hiding this comment.
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
Generated command documentation is stale, and SetTypeMeta does not support pointer slices as its generic API implies.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 3
- Review effort level: Balanced
| tm, ok := any(&items[i]).(interface { | ||
| SetGroupVersionKind(schema.GroupVersionKind) | ||
| }) | ||
| if !ok { | ||
| continue |
There was a problem hiding this comment.
this above file is from the list PR and is not used directly for cancel commands, once the other pr is merged, and I rebase this, this review should not be relevant anymore, therefore not addressing
| } | ||
|
|
||
| c.Flags().StringVarP(&graceCancelStatus, "grace", "", "", graceCancelDescription) | ||
| c.Flags().StringVarP(&output, "output", "o", "", formatted.OutputFlagUsage) |
| }, | ||
| } | ||
|
|
||
| c.Flags().StringVarP(&output, "output", "o", "", formatted.OutputFlagUsage) |
78e6c22 to
d5ff20c
Compare
|
New changes are detected. LGTM label has been removed. |
d5ff20c to
d57c9f7
Compare
|
/unhold |
…mmand for pipelinerun and taskrun
d57c9f7 to
682df74
Compare
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: pratap0007 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold We might need to re-think on the output format to meet the k8s standards. We can remove the hold once we conculde the discussion |
Changes
Added -o/--output flag to pipelinerun cancel and taskrun cancel
On success, when --output json or --output yaml is set, prints a structured result instead of the plain-text message: the examples are mentioned in the release notes
Default behavior (no --output flag) is unchanged — still prints PipelineRun cancelled:
Invalid --output values (e.g. csv) return a clear error
Error paths (e.g. cancelling an already-finished run) still return plain error text regardless of --output, so failures are never mistaken for valid structured output
Reuses the shared pkg/formatted.PrintStructuredOutput/IsStructured helpers; introduces a CancelResult{Kind, Name, Status} struct local to each command package
Updated --help examples for both commands to demonstrate -o json/-o yaml usage
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
make checkmake generatedSee the contribution guide
for more details.
Release Notes
tkn pipelinerun cancel and tkn taskrun cancel now support --output json and --output yaml
Both commands accept a new -o/--output flag to print the cancellation result as structured JSON or YAML instead of plain text — useful for scripts, automation, and AI agents that need machine-readable output.
Default (no --output flag) behavior is unchanged. An unsupported format (e.g. -o csv) returns a clear error.